package com.igeekhome.service.impl;

import com.igeekhome.mapper.DAdvancedCustomerAddressListMapper;
import com.igeekhome.pojo.DAdvancedCustomerAddressList;
import com.igeekhome.pojo.DAdvancedCustomerAddressListExample;
import com.igeekhome.service.ICustomerAddressListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 立以宁
 */
@Service("customerAddressList")
public class CustomerAddressListServiceImpl implements ICustomerAddressListService {

    @Autowired
    private DAdvancedCustomerAddressListMapper dAdvancedCustomerAddressListMapper;

    @Override
    public List<DAdvancedCustomerAddressList> selectAll(Integer customer_id) {

        DAdvancedCustomerAddressListExample example = new DAdvancedCustomerAddressListExample();
        DAdvancedCustomerAddressListExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(customer_id);
        List<DAdvancedCustomerAddressList> dAdvancedCustomerAddressLists = dAdvancedCustomerAddressListMapper.selectByExample(example);
        return dAdvancedCustomerAddressLists;
    }

    @Override
    public void updateAddressList(DAdvancedCustomerAddressList addressList) {
        dAdvancedCustomerAddressListMapper.updateByPrimaryKey(addressList);
    }

    @Override
    public void addAddressList(DAdvancedCustomerAddressList addressList) {
         dAdvancedCustomerAddressListMapper.insert(addressList);
    }

    @Override
    public DAdvancedCustomerAddressList selectCustomerAddress(Integer id) {
        DAdvancedCustomerAddressList dAdvancedCustomerAddressList = dAdvancedCustomerAddressListMapper.selectByPrimaryKey(id);
        return dAdvancedCustomerAddressList;
    }
}
